package com.smarthealthcare.wardrounds.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smarthealthcare.common.annotation.Log;
import com.smarthealthcare.common.core.controller.BaseController;
import com.smarthealthcare.common.core.domain.AjaxResult;
import com.smarthealthcare.common.enums.BusinessType;
import com.smarthealthcare.wardrounds.domain.Wardrounds;
import com.smarthealthcare.wardrounds.service.IWardroundsService;
import com.smarthealthcare.common.utils.poi.ExcelUtil;
import com.smarthealthcare.common.core.page.TableDataInfo;

/**
 * 查房信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/wardrounds/wardrounds")
public class WardroundsController extends BaseController
{
    @Autowired
    private IWardroundsService wardroundsService;

    /**
     * 查询查房信息列表
     */
    @PreAuthorize("@ss.hasPermi('wardrounds:wardrounds:list')")
    @GetMapping("/list")
    public TableDataInfo list(Wardrounds wardrounds)
    {
        startPage();
        List<Wardrounds> list = wardroundsService.selectWardroundsList(wardrounds);
        return getDataTable(list);
    }

    /**
     * 导出查房信息列表
     */
    @PreAuthorize("@ss.hasPermi('wardrounds:wardrounds:export')")
    @Log(title = "查房信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Wardrounds wardrounds)
    {
        List<Wardrounds> list = wardroundsService.selectWardroundsList(wardrounds);
        ExcelUtil<Wardrounds> util = new ExcelUtil<Wardrounds>(Wardrounds.class);
        util.exportExcel(response, list, "查房信息数据");
    }

    /**
     * 获取查房信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('wardrounds:wardrounds:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wardroundsService.selectWardroundsById(id));
    }

    /**
     * 新增查房信息
     */
    @PreAuthorize("@ss.hasPermi('wardrounds:wardrounds:add')")
    @Log(title = "查房信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Wardrounds wardrounds)
    {
        return toAjax(wardroundsService.insertWardrounds(wardrounds));
    }

    /**
     * 修改查房信息
     */
    @PreAuthorize("@ss.hasPermi('wardrounds:wardrounds:edit')")
    @Log(title = "查房信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Wardrounds wardrounds)
    {
        return toAjax(wardroundsService.updateWardrounds(wardrounds));
    }

    /**
     * 删除查房信息
     */
    @PreAuthorize("@ss.hasPermi('wardrounds:wardrounds:remove')")
    @Log(title = "查房信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wardroundsService.deleteWardroundsByIds(ids));
    }
}
